<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2018-03-02 17:14:35 apple $
*/
namespace core;
defined('BY_JYA') or exit('error');
class openapi_web{
	public function up_access($access){
		if($access['c']=='miniapp' && $access['a']=='version'){
			$access['action']='account.welcome';
		}
		if($access['c']=='user' && $access['a']=='logout'){
			$access['action']='user.logout';
		}
		if($access['c']=='site' && $access['a']=='entry'){
			$access['action']='module';
		}
		if($access['c']=='mc' && $access['a']=='fans'){
			$access['action']='wechat.fans';
		}
		if($access['c']=='mc' && $access['a']=='member'){
			$access['action']='member.member';
		}
		if($access['a']=='display' && $access['action']=='module'){
			$access['action']='account.welcome';
		}
		if($access['c']=='cloud' && $access['a']=='upgrade' && $access['action']=='module'){
			$access['action']='cloud.module';
			unset($access['a'],$access['c']);
		}elseif($access['c']=='system' && $access['a']=='updatecache' && $access['action']=='module'){
			$access['action']='system.cache';
			unset($access['a'],$access['c']);
		}elseif($access['c']=='home' && $access['a']=='welcome' && $access['action']=='module'){
			$access['action']='account.welcome';
			unset($access['a'],$access['c']);
		}
		$access['plugin']='core';
		if($access['action']!='module'){
			exi('','','core/'.$access['action'].'/');
		}
		return $access;
	}
	//批量替换
	public function open_jy_replace($plugin_name,$type=''){
		if(!$plugin_name){
			exi('请选择插件！','error');
		}
		$path=ROOT_PLUGIN.$plugin_name;
		$files=cfc('files')->file_tree($path);
		foreach($files as $file){
			if(is_file($path.$file)){
				$data=file_get_contents($path.$file);
				$pathinfo=pathinfo($path.$file);
				if($pathinfo['extension']=='php'){
					$data=$this->h5php($data);
					file_put_contents($path.$file,$data);	
				}elseif($pathinfo['extension']=='html'){
					
				}
			}
		}				
		return true;
	}
	public function h5php($html){
		$html=str_replace('/framework/','/core/',$html);	
		return $html;
	}
}